<template>
  <div class="Header">
    <p class="left">
      鸟类多体征智能监测巢箱管理系统
    </p>
    <div class="center">

        <div :class="{routeItem:true ,'active':item.click }"  v-for="(item,index) in roterList" :key="index">
          <p @click="toPath1(item , index)">{{ item.name }}</p>
          <div class="child-route" v-if=" item.children && item.children.length && clickIndex == index">
            <p v-for="(child , i) in item.children" :class="{childAct:childIndex==i}" :key="i" @click="toPath2(child , i)">{{ child.name }}</p>
          </div>
        </div>

    </div>
    <div class="right">
      <p>
        <span id="he-plugin-simple"></span>
      </p>
      <div class="time" style="width: 200px;">
        <p>{{time}} </p>
        <p>{{date}}</p>
      </div>

      <p>
        <img src="../assets/header/person.png" alt="">
      </p>
    </div>
  </div>
</template>

<script>
import {getDate} from '@/utils/date.js';
export default {
  name: "Header",
  props: [],
  data() {
    return {
      time: "",
      date: "",
      clickIndex: 0,
      childIndex: 0,
      timer:null,
      roterList : [
        {name:'数据看板',path:'/DataBoard'},
        {name:'监测数据',path:'/MonitoringData'},
        {name:'监测分析',path:'/MonitoringAnalysis'},
        {name:'直播中心',path:'/BroadcastCenter'},
        {name:'物种名录',path:'/ListOfSpecies'},
        {name:'智能巢箱',path:'/SystemSetting' , click: true ,
        children:[{ name :"巢箱监测" ,  path:"/SystemSetting/monitor" } , { name :"巢箱管理" ,  path:"/SystemSetting/manage" } ,] },
      ]
    };
  },

  computed: {},
  methods: {
    toPath1(item , index) {
      this.clickIndex = index
      if(!item.click) return ;
    },
    toPath2(item , index){

      if(this.childIndex==index) return ;
      this.childIndex = index;
      this.clickIndex = 0 ;
      this.$router.push({path: item.path})
    }
  },
  mounted() {
    let that = this;
      this.timer = setInterval(() => {
        that.time = getDate().time;
        that.date = getDate().date;
      }, 1000);
   
  }
};
</script>

<style lang="scss" scoped>
.Header {
  width: 100%;
  height: 82px;
  background: url('../assets/header/hd-bg.png') no-repeat ;
  background-size: 100% 100%;
  position: fixed;
  left: 0;
  top: 0;
  z-index: 999;
  display: flex;
  padding-top: 14px;
  justify-content: space-between;
  .left {
    font-family: PangMenZhengDao;
    font-size: 32px;
    margin-left: 44px;
    height: 32px;
    transform: translateY(-6px);
    font-weight: normal;
    letter-spacing: 4px;
    color: rgba(255, 255, 255, 0.9216);
    font-style: italic;
    text-shadow: 0px 0px 10px rgba(255, 255, 255, 0.3);
    margin-right: 12vw;
  }

  .center {
    margin-top: 8px;
    height: 26px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    .routeItem{
      font-family: PangMenZhengDao;
      font-size: 20px;
      font-weight: normal;
      position: relative;
      display: flex;
      align-items: center;
      letter-spacing: 0.05em;
      font-variation-settings: "opsz" auto;
      color: #FFFFFF;
      width: 112px;
      height: 26px;
      margin-right: 20px;
      >p {
        cursor: pointer;
        width: 100%;
        height: 100%;
        text-align: center;
        line-height: 26px;
      }

      .child-route {
        position: absolute;
        top: 36px;
        left: -10px;
        width: 132px;
        height: 80px;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: space-between;
        padding: 5px;
        opacity: 0.9;
        background: linear-gradient(90deg, rgba(115, 255, 247, 0.3) 0%, rgba(115, 255, 247, 0.07) 100%);
        >p {
          font-size: 16px;
          text-align: center;
          line-height: 30px;
          width: 115px;
          height: 30px;
          font-family: Source Han Sans;
          cursor: pointer;
        }
        .childAct {
          color: #B2FFB5;
          background: linear-gradient(270deg, rgba(178, 255, 181, 0.2) 0%, rgba(178, 255, 181, 0.37) 100%);
        }

      }
    }
    .active {
      background: url('../assets/header/btn-act.png') no-repeat;
      background-size: 100% 100%;
      >p {
        background: linear-gradient(180deg, #FBE749 41%, #D2FFD4 100%);
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
        background-clip: text;
        text-fill-color: transparent;
      }
    }
  }
  .right {

    margin-top: 8px;
    font-family: PangMenZhengDao;
    font-size: 14px;
    display: flex;
    img {
      width: 22px;
      margin-left: 12px;
      margin-right: 40px;
    }

    >div {
      display: flex;
      justify-content: space-between;
    }
  }
}
</style>
